export function require(msg,data){//提示   
	var json={ required:true, message: msg+'不能为空'  }
	if(data&&data.trigger){
		json.trigger=data.trigger||"blur"
	}
	if(data&&data.type){
		json.type=data.type
	}
	if(data&&data.require){
		json.required=data.require
	}
	return json
}

export function prop(val) {

	var prop={
		carBrandId:"汽车品牌",
	    carSubBrandId:"汽车子品牌",
	    carSeriesId:"汽车车系",
	    carTypeId:"汽车车型",
	    carConfig:"指导价/配置",
	    amount:"汽车数量",
	    color:"汽车颜色",
	    totalPrice:"购车总价格",
	    paymentAmount:"垫资金额",
	    earnest:"定金金额",
	    interestRate:"当前利率",
	    durationId:"借款时长",
	    priceStatus:"车辆基本信息是否确认",
	    supplierName:"合同上游名称",
	    supplierCityPid:"提车省",
	    supplierCity:"提车市",
	    supplierAddress:"提车具体地址",
	    supplierPerson:"提车联系人",
	    supplierPhone:"联系人手机号",
	    accountNumber:"收款账号",
	    accountName:"收款帐户名",
	    openningBank:"开户行名称",
	    supplierInfoStatus:"上游信息是否确认",
	    funderId:"资金方",
	    spvId:"SPV",
	    remark:"打款备注",
	    'orderAuditResults.upperReacherExamineResult':"上游购销合同审核结果",
	    'orderAuditResults.earnestExamineResult':"定金凭证审核结果",
        'orderAuditResults.supplierEstablishName':"供应商名称",
        'orderAuditResults.supplierEstablishTime':"供应商成立日期",
        'orderAuditResults.establishExamineResult':"供应商审核结果",
        'orderAuditResults.resourceProviderName':"资源商名称",
        'orderAuditResults.resourceProviderEstablishTime':"资源商成立日期",
        'orderAuditResults.resourceProviderExamineResult':"资源商审核结果",
        'dataChangeRecord':"资料更改记录",
        "orderAuditResults.carAddressExamineResult":"提车地址审核结果",



         mileage:"公里数"
    }
    return prop[val]?prop[val]:val

}

export function length30(rule, value, callback) {
   return { min: 0, max: 30, message: '长度不能超过30个字符', trigger: 'change' }
}

export function length100(rule, value, callback) {
   return { min: 0, max: 100, message: '长度不能超过100个字符', trigger: 'change' }
}

export function phone(rule, value, callback) {
   if (value === '') {
        callback(new Error("请填写手机号码"));
    } else if(!/^1[34578]\d{9}$/.test(value)){
		callback(new Error('请输入正确的手机号码'));
	}else {
      callback();
    }
}
export function decimal(rule, value, callback,number) {
   if(!/^[0-9\s]+$/.test(value)){
		callback(new Error('请输入正确的数字类型'));
	}else {
      callback();
    }
}
export function maxTenInt(rule, value, callback,number) {
   if(!/^\d{1,10}$/.test(value)){
		callback(new Error('请输入最多十位的正整数'));
	}else {
      callback();
    }
}
export function decimalTwo(rule, value, callback,number) {
   if(!/^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d{1,2})$/.test(value)){
		callback(new Error('请输入最多两位小数的正数'));
	}else {
      callback();
    }
}
export function decimalThree(rule, value, callback,number) {
   if(!/^([0-9]{0,10})(?:\.\d{1,3})?$/.test(value)){
		callback(new Error('请输入最多三位小数的正数'));
	}else {
      callback();
    }
}
export function decimalFour(rule, value, callback) {
   if(!/^([0-9]{0,10})(?:\.\d{1,4})?$/.test(value)){
		callback(new Error('请输入最多四位小数的正数'));
	}else {
      callback();
    }
}
export function max100(rule, value, callback) {
   if(value>100){
		callback(new Error('利率不能大于100'));
	}else {
      callback();
    }
}

export function isChinese(rule, value, callback)  {  
	if(/[^\u4e00-\u9fa5\/\\]/.test(value)){
		callback(new Error('请输入中文')); 
	}else {
      callback();
    }
}  
export function numOrEnglish(rule, value, callback)  {  
	if(!/^[A-Za-z0-9]+$/.test(value)){
		callback(new Error('请输入数字或者英文字母')); 
	}else {
      callback();
    }
}